package com.aim.util;

import java.util.HashMap;
import java.util.Map;

/**
 * User: Avraham Shvartzon
 * Date: 6/23/14
 */
public class ObjectCounter<KEY> extends HashMap<KEY, Integer>{

    private Map<KEY, Integer> countMap = new HashMap<KEY, Integer>();

    public void increase(KEY key){
        increase(key,1);
    }
    public void increase(KEY key, int increaseValue){
        Integer currentValue = get(key);
        if (currentValue == null){
            currentValue = 0;
        }
        currentValue += increaseValue;
        put(key, currentValue);
    }


    public Integer get(Object key){
        Integer value = super.get(key);
        return value != null? value : 0;
    }
}
